﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Models;
using Service.Interface;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebAPI.CustomFilter;

namespace WebAPI.Controllers
{
    /// <summary>
    /// 获取同步数据
    /// </summary>
    [ApiController]
    [Route("[controller]/[action]")]
    public class QuartzController : Controller
    {
        Result result = new Result(true);
        private readonly ILogger<ProcessController> _logger;
        private readonly IReportServices _reportservices;
        private readonly IShipmentServices _shipmentservices;

        public QuartzController(ILogger<ProcessController> logger, IReportServices reportservices,IShipmentServices shipmentServices)
        {
            _logger = logger;
            _reportservices = reportservices;
            _shipmentservices = shipmentServices;
        }

        /// <summary>
        /// 获取报工数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Result GetProcesReportData()
        {
            result.ReturnData = _reportservices.GetProcesReportData();
            return result;
        }

        /// <summary>
        /// OFN 不良信息同步
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Result ProductFail()
        {
            
            return new Result(_reportservices.ProductFail()); ;
        }

        /// <summary>
        /// 更新报工状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> UpdateProcesReport(List<LaborDetail> labors)
        {
            return new Result(await _reportservices.UpdateProcesReport(labors));
        }

        /// <summary>
        /// 查询报工数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Result GetLaborDetail(string jobnum, string company)
        {
            result.ReturnData = _shipmentservices.GetLaborDetail(jobnum, company);
            return result;
        }
    }
}
